﻿#region

using System.Collections.Generic;
using JsMapper.BO;
using StructureMap;

#endregion

namespace JsMapper.StandaloneExporter
{
    public static class JsMapperRepository
    {
        static JsMapperRepository()
        {
            Mappers = new List<IJsModelMapper>();

            ScanForMappers();
        }

        private static List<IJsModelMapper> Mappers { get; set; }

        private static void ScanForMappers()
        {
            var cont = new Container(x => x.Scan(scan =>
                {
                    scan.AddAllTypesOf<IJsModelMapper>();
                    scan.AssembliesFromApplicationBaseDirectory();
                }));

            Mappers = (List<IJsModelMapper>) cont.GetAllInstances<IJsModelMapper>();
        }

        public static IEnumerable<IJsModelMapper> GetAll()
        {
            return Mappers;
        }
    }
}